/*********************************************************************************
 *      Copyright:  (C) 2022 Zhukaifa（928085237@qq.com）
 *                  All rights reserved.
 *
 *       Filename:  thread_init.c 
 *
 *    Description:   Before creating a thread Initialize the

 *                 
 *        Version:  1.0.0(28/07/22)
 *         Author:  Zhukaifa（928085237@qq.com）
 *      ChangeLog:  1, Release initial version on "28/07/22 21:52:04"
 *                 
 ********************************************************************************/


#include "thread_init.h"

 
 
/*********************************************************************************
 *
 *           Name:     thread_init 
 *
 *    Description:     Before creating a thread Initialize the


 *                 
 *        Input args:     
 *                     thread_attr:A structure that holds thread properties
 *
 *       Output args: 
 *
 *      return value:   
 *                     =0 success
 *                     <0 failure
 *
 *                 
 ********************************************************************************/



int thread_init(pthread_attr_t *thread_attr)
{
/* thread init */

	if( pthread_attr_init(thread_attr) )
	{
		printf("pthread_attr_init() failure: %s\n", strerror(errno));
		return -1;
	}

	if( pthread_attr_setstacksize(thread_attr, 120*1024) )
	{ printf("pthread_attr_setstacksize() failure: %s\n", strerror(errno));
		return -1;

	}

	if( pthread_attr_setdetachstate(thread_attr, PTHREAD_CREATE_DETACHED) )
	{
		printf("pthread_attr_setdetachstate() failure: %s\n", strerror(errno));
		return -1;
	}


	return 0;
}
